<?php
/**
 * Created by PhpStorm.
 * User: C。
 * Date: 2019/8/13
 * Time: 9:04
 */
namespace app\home\controller;

use app\common\model\Banner as BannerModel;

/**
 * Banner控制器
 * Class Banner
 * @package app\home\controller
 */
class Banner extends Base
{
    /**
     * [getIndex  获取banner]
     * @param
     * @return json
     * @author [C。]
     */
    public function getIndex()
    {
        $model = new BannerModel();
        $param = input('param.');
        $map = [];
        try{
            $map['type'] = $param['type'];
            $map['status'] = 1;
//            $lists = $this->redis->get($_SERVER['SERVER_NAME'].'bannerindex'.$param['type']);
//            if(!$lists){
                $lists = $model->getListByFields($map,'pic_url,url,utype');
                foreach($lists as $k=>$v){
                    $http = substr($v['pic_url'],0,4);
                    if($http != 'http'){
                        $lists[$k]['pic_url'] = config('group_domain_name').$v['pic_url'];
                    }else{
                        $lists[$k]['pic_url'] = $v['pic_url'];
                    }
                }
//                $this->redis->set($_SERVER['SERVER_NAME'].'bannerindex'.$param['type'],$lists,360);
//            }
        }catch(\Exception $e){
            systembug($e->getMessage(),2,'home/Banner/getIndex');
            return admin_json(-1, '获取失败'.$e->getMessage());
        }
        return admin_json(1, '获取成功',$lists);
    }
    /**
     * [getIndex  获取banner]
     * @param
     * @return json
     * @author [C。]
     */
    public function getMp3()
    {
        try{
            $config = get_config();
        }catch(\Exception $e){
            systembug($e->getMessage(),2,'home/Banner/getMp3');
            return admin_json(-1, '获取失败'.$e->getMessage());
        }
        if(!empty($config['home_mp3'])){
            return admin_json(1, '获取成功',$config['home_mp3']);
        }else{
            return admin_json(2, '音乐不存在');
        }
    }
    /**
     * [getIndex  获取banner]
     * @param
     * @return json
     * @author [C。]
     */
    public function getOos()
    {
        $oos = config('oos');
        return admin_json(1, '获取成功',$oos);
    }
    /**
     * [getIndex  获取banner]
     * @param
     * @return json
     * @author [C。]
     */
    public function ceshioos()
    {
        $oos = array(
            'accessKeyId' => 'LTAIUZZ0EO0Xlz0c',
            'accessKeySecret' => 'ZPPOxFBERpKvaw4uO5oZVbdgnd5cRd ',
            'bucket' => 'fushance',
            'regin' => 'oss-cn-beijing',
            'image_url' => 'fushance.oss-cn-beijing.aliyuncs.com',
        );
        return admin_json(1, '获取成功',$oos);
    }
    /**
     * [getIsshow  获取是否隐藏结缘寺院]
     * @param
     * @return json
     * @author [C。]
     */
    public function getIsshow()
    {
        $res = get_config();
        $data['jie_yuan_is_show'] = $res['jie_yuan_is_show'];
        return admin_json(1, '获取成功',$data);
    }
}